package com.tyler.ack;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

import java.nio.charset.StandardCharsets;

/**
 * @author: TylerZhong
 * @description:
 */
public class SyncSendProducer {
    public static void main(String[] args) throws MQClientException, MQBrokerException, RemotingException, InterruptedException {
        DefaultMQProducer producer = new DefaultMQProducer("SyncSendProducerGroup");
        producer.setNamesrvAddr("192.168.56.191:9876");
        producer.start();

        Message message = new Message("Order","tag","order info : orderId = xxx".getBytes(StandardCharsets.UTF_8));
        // 同步发送
        SendResult sendResult = producer.send(message);
        System.out.println(sendResult);

        Thread.sleep(3000);
        producer.shutdown();
    }
}
